package com.xbts.web.controller.manager;

import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.core.domain.Setting;
import com.xbts.system.service.SettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author llk
 * @Date 2023/8/14 13:57
 */
@Api("系统设置")
@RestController
@RequestMapping("/system/setting")
public class SystemSettingController extends BaseController {

    @Autowired
    private SettingService settingService;

    /**
     * SettingEnum
     * 查询系统设置
     */
    @ApiOperation("查询系统设置")
    @GetMapping("/list")
    public AjaxResult list(String key) {
        return AjaxResult.success(settingService.get(key));
    }

    /**
     * 修改系统设置
     */
    @ApiOperation("修改系统设置")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody Setting setting) {
        boolean b = settingService.saveUpdate(setting);
        if (!b) {
            return AjaxResult.error("修改失败");
        }
        return AjaxResult.success();
    }
}
